package com.example.mobile2021606185zhn0507;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import org.w3c.dom.Text;

public class ShowDataActivity extends AppCompatActivity {

    private TextView tvShowDataUserName;
    private TextView tvShowDataPassword;
    private TextView tvMainSupplier;
    private Button btnMainSelect;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_data);
        initView();
        btnMainSelect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ShowDataActivity.this,SupplierActivity.class);
                startActivityForResult(intent,1);
            }
        });


        Intent intent = getIntent();

        tvShowDataUserName.setText(intent.getStringExtra("userName"));
        tvShowDataPassword.setText(intent.getStringExtra("passWord"));
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == 1&&resultCode ==RESULT_OK){
            tvMainSupplier.setText(data.getStringExtra("supplier"));
        }
    }
    private void initView() {
        tvShowDataUserName = (TextView) findViewById(R.id.tvShowDataUserName);
        tvShowDataPassword = (TextView) findViewById(R.id.tvShowDataPassword);
        tvMainSupplier = (TextView) findViewById(R.id.tvMainSupplier);
        btnMainSelect = (Button) findViewById(R.id.btnMainSelect);
    }
}